package com.tianji.learning.controller;

import com.tianji.api.dto.leanring.LearningLessonDTO;
import com.tianji.api.dto.leanring.LearningRecordDTO;
import com.tianji.learning.domain.LearningRecord;
import com.tianji.learning.domain.dto.LearningRecordFormDTO;
import com.tianji.learning.service.LearningRecordService;
import com.tianji.learning.service.impl.LearningRecordServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description LearningRecordsController
 * @Author WJH
 * @Date 2024-12-19
 */

@RestController
@RequestMapping("/learning-records")
@Api(value = "学习记录相关接口")
public class LearningRecordsController {
    @Autowired
    private LearningRecordService learningRecordService;


    /**
     * 查询当前用户指定课程的学习进度
     * @param courseId 课程id
     * @return 课表信息、学习记录及进度信息
     */
    @GetMapping("/course/{courseId}")
    @ApiOperation("查询学习记录")
    LearningLessonDTO queryLearningRecordByCourse(@PathVariable("courseId") Long courseId){
        return learningRecordService.queryLearningRecordByCourse(courseId);

    }


    @PostMapping
    @ApiOperation("提交学习记录")
    public void commitLearningRecords(@RequestBody LearningRecordFormDTO learningRecordFormDTO){
        learningRecordService.commitLearningRecords(learningRecordFormDTO);
    }
}
